#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include <cstdlib>
#include <iostream>
#include <string>

#define PIPEFILE "./myfifo"
#define MODE 0666

#define SIZE 1024

using namespace std;

enum { FIFO_CREATE_ERR = 1, FIFO_DELETE_ERR, FIFO_OPEN_ERR };

class PipeInit {
 public:
  PipeInit() {
    int n = mkfifo(PIPEFILE, MODE);
    if (n == -1) {
      cerr << "CREATE PIPE FAIL" << endl;
      exit(FIFO_CREATE_ERR);
    }
  }
  ~PipeInit() {
    int m = unlink(PIPEFILE);
    if (m == -1) {
      cerr << "DEL PIPE FAIL" << endl;
      exit(FIFO_DELETE_ERR);
    }
  }
};